package com.heima.comment.controller.v1;

import com.heima.comment.service.CommentRepayService;
import com.heima.model.comment.dtos.CommentRepayDTO;
import com.heima.model.comment.dtos.CommentRepayLikeDTO;
import com.heima.model.comment.dtos.CommentRepaySaveDTO;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.validator.ValidatorSaveComment;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author huan
 * @serial 每天一百行, 致敬未来的自己
 * @Description
 */
@RestController
@Api(value = "评论回复API", tags = "评论回复API")
@RequestMapping("/api/v1/comment_repay")
public class CommentRepayController {

    @Autowired
    CommentRepayService commentRepayService;

    @ApiOperation("评论回复功能")
    @PostMapping("/save")
    public ResponseResult saveCommentRepay(@RequestBody @Validated({ValidatorSaveComment.class}) CommentRepaySaveDTO dto) {
        return commentRepayService.save(dto);
    }

    @PostMapping("/like")
    @ApiOperation("点赞回复的评论")
    public ResponseResult saveCommentRepayLike(@RequestBody CommentRepayLikeDTO dto) {
        return commentRepayService.saveCommentRepayLike(dto);
    }

    @PostMapping("/load")
    @ApiOperation("查看更多回复内容")
    public ResponseResult loadCommentRepay(@RequestBody CommentRepayDTO dto) {
        return commentRepayService.loadCommentRepay(dto);
    }
}
